package com.capybara.account.config;


import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * 配置
 *
 * @author guochaowang
 * @date 2024/09/20
 */
@Data
@Configuration
public class MyConfig {
    /**
     * 文件路径
     */
    @Value("${my.file.path:classpath}")
    private String filePath;


    /**
     * 获取文件路径
     *
     * @return 字符串
     */
    public String getFilePath() {
        if ("classpath".equals(filePath)) {
            File file = null;
            try {
                file = ResourceUtils.getFile("classpath:");
                filePath = file.getAbsolutePath();
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }

        }
        return filePath;
    }
}
